package com.tiancheng.trade.gateway.auth;

import lombok.Data;

import java.io.Serializable;

/**
 * @Author: kellen
 * @Description: 认证异常返回
 * @Date: create in 2024/11/18 15:58
 */
@Data
public class AuthExceptionResult implements Serializable {
    private Integer errorCode;
    private String msg;
    private Integer ret;
    private String traceId;

    public AuthExceptionResult() {
        this.errorCode = 0;
        this.msg = "success";
        this.ret = 0;
    }


    public static AuthExceptionResult success() {
        return new AuthExceptionResult();
    }

    public static AuthExceptionResult fail(int errorCode, String msg) {
        if (errorCode == 0) {
            throw new IllegalArgumentException("errorcode can't be 0");
        } else {
            AuthExceptionResult result = new AuthExceptionResult();
            result.setErrorCode(errorCode);
            result.setMsg(msg);
            result.setRet(1);
            return result;
        }
    }
}
